package com.health.gateway.custom;

import com.health.core.exception.MyException;
import com.health.core.util.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice //被这个注解标记的类就会成为全局的异常处理类
public class AcceptException {


    @ExceptionHandler(value = MyException.class)
    public Object getMessage(MyException customMessage){
        String message = customMessage.getMessage();
        return new R(Integer.parseInt(customMessage.getErrorCode()),message);
    }

    @ExceptionHandler(value = Exception.class)
    public Object getAllMessage(Exception e){
//        e.printStackTrace();
        return R.failed("服务内部错误");
    }



}